package com.norbitltd.guavaleaves.java.util;

import java.util.Date;

import org.apache.commons.lang3.time.DateUtils;

import com.google.common.base.Predicate;
import com.norbitltd.guavaleaves.java.lang.ObjectPredicates;

public class DatePredicates extends ObjectPredicates{

	/**
	 * @see org.apache.commons.lang3.time.DateUtils.isSameDay
	 */
	public Predicate<Date> isSameDay(final Date d) {
		return new Predicate<Date>() {
			public boolean apply(Date input) {
				return DateUtils.isSameDay(input, d);
			}	
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.time.DateUtils.isSameInstant
	 */
	public Predicate<Date> isSameInstant(final Date d) {
		return new Predicate<Date>() {
			public boolean apply(Date input) {
				return DateUtils.isSameInstant(input, d);
			}
		};
	}
	
	/**
	 * @see org.apache.commons.lang3.time.DateUtils.truncatedEquals
	 */
	public Predicate<Date> truncatedEquals(final Date d, final int field) {
		return new Predicate<Date>() {
			public boolean apply(Date input) {
				return DateUtils.truncatedEquals(input, d, field);
			}
		};
	}
	
	/**
	 * @see java.util.Date.after
	 */
	public Predicate<Date> after(final Date d) {
		return new Predicate<Date>() {
			public boolean apply(Date input) {
				return input.after(d);
			}
		};
	}
	
	/**
	 * @see java.util.Date.before
	 */
	public Predicate<Date> before(final Date d) {
		return new Predicate<Date>() {
			public boolean apply(Date input) {
				return input.before(d);
			}
		};
	}

}
